#include <stdio.h>
#include <math.h>

const float Pai=3.1415926f;

float absf(float a){
    if(a<0)
        return -a;
    return a;
}

const int  Num=100;

int formatInt(float f){
    int tmp=(int)f;
    int end=(f-tmp)>=0.5f?1:0;
    return tmp+end;
}

int main(){
    int n;
    int x1,y1,r1,x2,y2,r2,p;
    int i;
    scanf("%d",&n);
    float area=0;
    for(i=0;i<n;i++)
    {
        scanf("%d %d %d %d %d %d %d",&x1,&y1,&r1,&x2,&y2,&r2,&p);
        if(r1<r2)
        {
            int a=r1;
            r1=r2;
            r2=a;

            a=x1;
            x1=x2;
            x2=a;

            a=y1;
            y1=y2;
            y2=a;
        }

        float jl=sqrtf((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        float area1=Pai*r1*r1;
        float area2=Pai*r2*r2;
       
        //2个圆不相交
        if(jl>=r1+r2)
        {
            area=area1+area2;
        }  
        //大圆包含小圆
        else if(jl+r2<=r1)
        {
            area=area1;
        } 
        else if(jl<r1+r2)
        {
            float cosa=((jl*jl)+r1*r1-r2*r2)/2/jl/r1;
            float cosb=((jl*jl)+r2*r2-r1*r1)/2/jl/r2;
            float anglea=acos(cosa);
            float angleb=acos(cosb);

            //小圆的圆心角小于180度
            // if(angleb<Pai)
            // {
            float addArea=anglea*r1*r1
            +angleb*r2*r2-sin(anglea)*r1*jl;

            area=area1+area2-addArea;
            // }

           
        }
        
        float result=area*p;

        result*=Num;
        int tmp=formatInt(result);
        result=1.0f*tmp/Num;
        printf("%.2f\n",result);
        
    }
    return 0;
}